package com.example.chamberlainserver.Service.impl;

import com.example.chamberlainserver.Entry.Role;
import com.example.chamberlainserver.Service.RoleService;
import com.example.chamberlainserver.mapper.RoleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 角色服务实现类
 */
@Service
public class RoleServiceImpl implements RoleService {

    @Autowired
    private RoleMapper roleMapper;

    @Override
    public Role getRoleById(Integer id) {
        return roleMapper.getRoleById(id);
    }

    @Override
    public Role getRoleByCode(String roleCode) {
        return roleMapper.getRoleByCode(roleCode);
    }

    @Override
    public List<Role> getAllRoles() {
        return roleMapper.getAllRoles();
    }

    @Override
    public boolean addRole(Role role) {
        return roleMapper.insertRole(role) > 0;
    }

    @Override
    public boolean updateRole(Role role) {
        return roleMapper.updateRole(role) > 0;
    }

    @Override
    public boolean deleteRole(Integer id) {
        return roleMapper.deleteRoleById(id) > 0;
    }
}